package com.web.rss;

import java.awt.Dimension;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;

import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import com.web.rss.gui.Display;

public class TestPack {

	
	public static void main (String args[]) {

		/*
		 * Feed List : 
		 * http://www.lemonde.fr/rss/sequence/0,2-3246,1-0,0.xml Culture
		 * http://www.lemonde.fr/rss/sequence/0,2-651865,1-0,0.xml Technologie
		 * http://www.lemonde.fr/rss/sequence/0,2-3476,1-0,0.xml Cinéma
		 * http://www.lemonde.fr/rss/sequence/0,2-3260,1-0,0.xml Livres
		 * http://www.lemonde.fr/rss/fil/0,57-0,64-823353,0.xml Politique
		 * 
		 */
		
		try {
		    // Set System L&F
	        UIManager.setLookAndFeel(
	            UIManager.getSystemLookAndFeelClassName());
	    } 
	    catch (UnsupportedLookAndFeelException e) {
	       // handle exception
	    }
	    catch (ClassNotFoundException e) {
	       // handle exception
	    }
	    catch (InstantiationException e) {
	       // handle exception
	    }
	    catch (IllegalAccessException e) {
	       // handle exception
	    }
		
		
		try {
			HashMap<String, URL> list = new HashMap<String, URL>();
			list.put("Le Monde - Culture", new URL("http://www.lemonde.fr/rss/sequence/0,2-3246,1-0,0.xml"));
			list.put("Le Monde - Technologie",new URL("http://www.lemonde.fr/rss/sequence/0,2-651865,1-0,0.xml"));
			list.put("Le Monde - Cinéma",new URL("http://www.lemonde.fr/rss/sequence/0,2-3476,1-0,0.xml"));
			list.put("Le Monde - Livres",new URL("http://www.lemonde.fr/rss/sequence/0,2-3260,1-0,0.xml"));
			list.put("Le Monde - Politique",new URL("http://www.lemonde.fr/rss/fil/0,57-0,64-823353,0.xml"));
			Display display = new Display("fr", new Dimension (640,480), list);
			display.setTitle("RSS Reader - Testing");
			display.setVisible(true);
		}
		catch (MalformedURLException ex) {
			
		}
		/*
		try {
			System.out.println("testing feed contents.");
			SyndFeedInput input = new SyndFeedInput();
			URL url = new URL("http://www.lemonde.fr/rss/sequence/0,2-3246,1-0,0.xml");
			SyndFeed feed;
			SyndEntryImpl entry;
			feed = input.build(new XmlReader(url));
			Iterator<SyndEntryImpl> iter = feed.getEntries().iterator();
			SyndContent contents;
			int i = 0;
			while ((iter.hasNext()) && (i < 5)) {
				entry = iter.next();
				System.out.println("Titre : " + entry.getTitle());
				//System.out.println(entry.getDescription());
				contents = entry.getDescription();
				System.out.println(contents.getValue());
				i++;
			}
		}
		catch (MalformedURLException ex) {
			System.out.println("Oops.");
		} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (FeedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		*/
	}
}
